package com.gitee.melin.bee.core.jdbc.dialect;

import com.gitee.melin.bee.core.jdbc.QueryResult;
import com.gitee.melin.bee.core.jdbc.enums.DataSourceType;
import com.gitee.melin.bee.core.jdbc.relational.*;
import java.sql.Statement;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.sql.DataSource;

public interface JdbcDialect extends AutoCloseable {

    default DataSource getNativeDataSource() {
        return null;
    }

    default List<MetaProcedure> getProcedures(String catalogName, String schemaPattern, String functionNamePattern) {
        throw new UnsupportedOperationException("Method getProcedures not supported");
    }

    default List<MetaFunction> getFunctions(String catalogName, String schemaPattern, String functionNamePattern) {
        throw new UnsupportedOperationException("Method getFunctions not supported");
    }

    /* 返回数据库默认函数 */
    default List<String> getSystemFunctions() {
        throw new UnsupportedOperationException("Method getSystemFunctions not supported");
    }

    default List<String> getSqlKeywords() {
        throw new UnsupportedOperationException("Method getSqlKeywords not supported");
    }

    default List<MetaTypeInfo> getMetaTypeInfos() {
        throw new UnsupportedOperationException("Method getMetaTypeInfos not supported");
    }

    DataSourceType getDataSourceType();

    MetaDataSource testConnection(ConnectionInfo connectionInfo);

    DatabaseVersion getDatabaseVersion();

    List<String> getDatabases();

    List<String> getSchemas();

    MetaTable getSchemaTable(String schemaName, String tableName, boolean containColumn);

    List<String> getTableNames(String schemaName);

    List<SimpleMetaTable> getSimpleTables(String schemaName);

    List<MetaTable> getSchemaTables(String schemaName);

    LinkedHashSet<String> getPrimaryKeys(String schemaName, String tableName);

    List<MetaColumn> getSchemaColumns(String schemaName, String tableName);

    String getCreateTableScript(BeeTableType type, String schemaName, String tableName);

    Statement getQueryStatement();

    CompletableFuture<QueryResult> asyncQuery(String sql);

    CompletableFuture<QueryResult> asyncQuery(String schema, String sql);

    CompletableFuture<QueryResult> asyncQuery(String sql, int maxRecords);

    CompletableFuture<QueryResult> asyncQuery(String schema, String sql, int maxRecords);

    QueryResult query(String sql);

    QueryResult query(String schema, String sql);

    QueryResult query(String sql, int maxRecords);

    QueryResult query(String schema, String sql, int maxRecords);

    long queryCount(String sql, Object... params);

    List<Map<String, Object>> queryForList(String sql, Object... params);

    Boolean execute(String sql);

    Boolean execute(String schema, String sql);

    CompletableFuture<Boolean> asyncExecute(String sql);

    CompletableFuture<Boolean> asyncExecute(String schema, String sql);

    Integer executeUpdate(String sql, Object... params);

    Integer executeUpdate(SchemaIdentifier schema, String sql, Object... params);

    CompletableFuture<Integer> asyncExecuteUpdate(String sql, Object... params);

    CompletableFuture<Integer> asyncExecuteUpdate(SchemaIdentifier schema, String sql, Object... params);
}
